@extends('layouts.admin.layout')

@section('content')
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑管理员</strong> / <small>Edit</small></div>
            </div>

            <hr>
            @include('layouts.admin._flash')
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form am-form-horizontal" action="{{route('auth.admin_update',$admin->id)}}" method="post">
                        {!! csrf_field() !!}
                        {{ method_field('PUT') }}
                        <div class="am-form-group">
                            <label for="doc-select-1" class="am-u-sm-2 am-form-label">用户组</label>
                            <div class="am-u-sm-10">
                                <select multiple id="doc-select-1" name="role_id[]">
                                    @foreach($roles as $role)
                                        <option @if(in_array($role->id,$admin->roles->pluck('id')->all())) selected @endif value="{{$role->id}}">{{$role->label}}</option>
                                    @endforeach
                                </select>
                            </div>

                            <span class="am-form-caret"></span>
                        </div>

                        <div class="am-form-group">
                            <label for="doc-ipt-1" class="am-u-sm-2 am-form-label">用户名</label>
                            <div class="am-u-sm-10">
                                <input type="text" name="name" id="doc-ipt-1" value="{{$admin->name}}">
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="doc-ipt-3" class="am-u-sm-2 am-form-label">邮件</label>
                            <div class="am-u-sm-10">
                                <input type="email" name="email" id="doc-ipt-3" value="{{$admin->email}}" disabled>
                            </div>
                        </div>


                        <div class="am-form-group">
                            <label for="doc-ipt-pwd-2" class="am-u-sm-2 am-form-label">密码</label>
                            <div class="am-u-sm-10">
                                <input type="password" name="password" id="doc-ipt-pwd-2" placeholder="设置一个新密码吧">
                            </div>
                        </div>

                        <div class="am-form-group">
                            <div class="am-u-sm-10 am-u-sm-offset-2">
                                <button type="submit" class="am-btn am-btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
        </div>
@endsection